package com.lap.generator.infrastructure.query;

import com.lap.generator.domain.valueobject.ModelType;

public class JavaTypeMapper {

  public static ModelType map(String dbType, String maxLength) {
    return switch (dbType.toLowerCase()) {
      case "tinyint" -> ModelType.of("Integer", "-127", "128");
      case "smallint" -> ModelType.of("Integer", "-32768", "32767");
      case "integer", "int" -> ModelType.of("Integer", "0", String.valueOf(Integer.MAX_VALUE));
      case "bigint" -> ModelType.of("Long", "0", String.valueOf(Integer.MAX_VALUE));
      case "decimal", "numeric" ->
          ModelType.of("BigDecimal", "0", String.valueOf(Integer.MAX_VALUE));
      case "float", "double" -> ModelType.of("Double", "0", String.valueOf(Integer.MAX_VALUE));
      case "date" -> ModelType.of("LocalDate", null, null);
      case "datetime", "timestamp" -> ModelType.of("LocalDateTime", null, null);
      case "time" -> ModelType.of("LocalTime", null, null);
      case "bit", "boolean" -> ModelType.of("Boolean", null, null);
      default -> ModelType.of("String", null, maxLength);
    };
  }
}
